home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-04-16 | 5.2 KB | 111 lines | [TEXT/GEOL] |
- Item forwarded by A33 to A34
-
- Item 3568245 12-April-90 12:55PDT
-
- From: POWERUP.ENG Power Up Software,PRT
-
- To: MACAPP.TECH$ MacApp Technical
- ROSENSTEIN1 Rosenstein, Larry
-
- Sub: Re-MacApp and code resour
-
- Attn: MacApp.Tech$
- Attn: Larry Rosenstein
- SentBy: James Plamondon
- Date 4/13/90
- Subject Re-MacApp and code resourc
- From James Plamondon
- To EHN & DIJ Oakley,IDV, Larry Rosenstein
- CC MacApp.Tech$
-
- Subject: Re-MacApp and code resourc
- Dear Larry, Howard, et al.,
-
- Thanks for your responses to my link regarding the use of external code
- resources in MacApp.
-
- To sum up your responses: one cannot write an external code resource (such as
- an XCMD, an MDEF, etc.) in Object Pascal, but one can access such an external
- code resource from Object Pascal and (thus) from a MacApp program just as one
- would from any other kind of program.
-
- Assuming that this summation is correct, let me take this discussion a step
- further — to wrapping up the external code resources in a class, as Larry
- mentioned one could do.
-
- One can imagine a class, TCust, which encapsulates a custom code resource such
- as that described in Tech Note #135 (Getting Through CUSToms), and another
- class, TCustManager, which deals with groups of TCust objects.
-
- The TCustManager class could search in the appropriate places (folders and/or
- files) for resources of type 'CUST' (exactly how this is done is not
- relevant). For each 'CUST' resource found, it would create a new object of
- class TCust, and keep track of it somehow (in a list or some such — again, the
- details don't matter). Each TCust object would contain a reference to the
- ‘CUST’ resource it encapsulated (of course). The TCust class would contain
- wrappers for whatever messages the 'CUST' resource recognized. For example,
- ICust() would send the 'CUST' resource an initialization message, TCust.Free()
- could send it a cleanup message, and various other methods would send other,
- appropriate messages.
-
- Of course, sending a message to a code resource is not implemented in the same
- way as sending a message to an object. Just as in a WDEF, CDEF, MDEF, or any
- other code resource, the code resource's main routine is called with a integer
- message selector.
-
- In the 'CUST' Tech Note (#135), Rick Blair, the author, recommends passing in
- the address of some of the application's globals as a parameter to the 'CUST'
- resource's main routine. I think that this is generally frowned on now, and
- that instead, a reference to a parameter block is passed in instead, along
- with the message selector.
-
- So, the MacApp application can communicate just fine with the 'CUST'
- resources, because they are neatly encapsulated in TCust objects. But, can
- the 'CUST' resources communicate back to the MacApp application? They
- certainly can't make method calls, even if they are given references to MacApp
- objects, because these methods weren't linked into the 'CUST' resources.
-
- What the 'CUST' resources CAN do is call a single global routine — let's call
- it RequestService() — in the MacApp application. Each 'CUST' resource is
- passed a reference to this global routine (which must reside in a locked
- segment) during its initialization, along with a reference to the TCust object
- that encapsulates it. The 'CUST' resource calls RequestService(), passing in
- a message selector, the reference to its TCust wrapper, and a parameter block.
- RequestService() then calls the given TCust object's TCust.RequestService()
- method with the given info. TCust.RequestService() contains a big, ugly CASE
- statement on the message selector. Each of the various case clauses can do
- whatever it needs to do, including calling MacApp methods. Thus, the ‘CUST’
- resource can communicate with MacApp.
-
- In summary, it appears to me that it is not only possible, but downright easy
- to use custom resources such as XCMDs to extend programs written in MacApp.
- While it’s true that such external resources cannot themselves be written in
- MacApp, or even in Object Pascal, this is no great hardship; the mechanism of
- having the code resource call an application global routine with a
- message-selector-and-parameter-block to request services of the application
- has to be done in non-MacApp programs too, and in them, it is usually less
- well encapsulated than it would be in a MacApp program.
-
- Why am I so interested in this? Because, first of all, I’m planning to use
- external code resources in my MacApp program, and I want to make sure there
- are no wholes in my proposed mechanism before I spend a lot of time
- implementing it.
-
- Also, I’m interested because my ex-associate was actually WRITING HIS OWN
- OBJECT SYSTEM FROM SCRATCH because somebody told him that he couldn’t use
- external code resources in MacApp. Think of the incredible amount of time
- he’s going to waste! I’d love to be able to set him straight, and save him
- about ten man-years of development time — but only if my scheme will work (of
- course).
-
- So — can anybody find any big theoretical or practical problems with the
- scheme I’ve outlined above? I deeply appreciate your assistance in this
- matter.
-
- Looking forward to your responses, I remain
-
- Yours,
-
- James Plamondon
-
-